<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
	<meta name="author" content="JFinalShop Team">
	<meta name="copyright" content="JFinalShop">
	<title>${message("business.stock.log")} - Powered By JFinalShop</title>
	<link href="${base}/favicon.ico" rel="icon">
	<link href="${base}/resources/business/css/bootstrap.css" rel="stylesheet">
	<link href="${base}/resources/business/css/font-awesome.css" rel="stylesheet">
	<link href="${base}/resources/business/css/bootstrap-select.css" rel="stylesheet">
	<link href="${base}/resources/business/css/animate.css" rel="stylesheet">
	<link href="${base}/resources/business/css/adminLTE.css" rel="stylesheet">
	<link href="${base}/resources/business/css/common.css" rel="stylesheet">
	<!--[if lt IE 9]>
		<script src="${base}/resources/business/js/html5shiv.js"></script>
		<script src="${base}/resources/business/js/respond.js"></script>
	<![endif]-->
	<script src="${base}/resources/business/js/jquery.js"></script>
	<script src="${base}/resources/business/js/bootstrap.js"></script>
	<script src="${base}/resources/business/js/bootstrap-select.js"></script>
	<script src="${base}/resources/business/js/velocity.js"></script>
	<script src="${base}/resources/business/js/velocity.ui.js"></script>
	<script src="${base}/resources/business/js/icheck.js"></script>
	<script src="${base}/resources/business/js/adminLTE.js"></script>
	<script src="${base}/resources/business/js/common.js"></script>
	<script type="text/javascript">
	$().ready(function() { 
		var $delete = $("#delete");
		var $checkAll = $("[data-toggle='checkAll']");
		var $ids = $("input[name='ids']");
		
		var $printModal = $("#printModal");
		var $printSelect = $("#printSelect");
		var $printButton = $("#printButton");
		var $print = $("a.print");
		var purchaseId;
		var isDelivery;
		
		[#if flashMessage?has_content]
			$.alert("${flashMessage}");
		[/#if]
		
		// 删除
		$delete.deleteItem({
			url: "${base}/admin/unit/delete",
			data: function() {
				return $ids.serialize();
			},
			removeElement: function() {
				return $ids.filter(":checked").closest("tr");
			},
			complete: function() {
				$ids = $("input[name='ids']");
				$delete.add($shelves).add($shelf).attr("disabled", true);
				$checkAll.checkAll("uncheck");
				if ($ids.size() < 1) {
					setTimeout(function() {
						location.reload(true);
					}, 3000);
				}
			}
		});
		
		
		
		// 删除
		$("[name=a_unit_delete]").click(function(){
			if (confirm("确定要删除吗？")) {
			$("[name=a_unit_delete]").attr('disabled',true); 
			$("[name=a_unit_update]").attr('disabled',true); 
			var unitId = $(this).parent().siblings().find("#input_unit_id").val();
			var idArray = new Array();
			idArray[0] = unitId;
			$.ajax({
				type: "POST",
				url: "${base}/admin/unit/delete",   
				data: {
					"ids": idArray
					},  
            	contentType: "application/x-www-form-urlencoded; charset=utf-8",     
            	dataType: "json",     
            	success: function() {
            		alert("删除成功!");
            		location.reload();
            	}    
			});
			}else {
			
			}
		});
		
		// 编辑
		$("[name=a_unit_edit]").click(function(){
			var unitId = $(this).parent().siblings().find("#input_unit_id").val();
			var unitName = $(this).parent().siblings().find("[name=input_unit_name]").val();
			var idArray = new Array();
			idArray[0] = unitId;
			$.ajax({
				type: "POST",
				url: "${base}/admin/unit/edit",   
				data: {
					"unit.id": unitId,
					"unit.name": unitName
					},  
            	contentType: "application/x-www-form-urlencoded; charset=utf-8",     
            	dataType: "json",     
            	success: function() {
            	}    
			});
			
		});
		
		
		
		// ID多选框
		$ids.on("ifChanged", function() {
			$delete.attr("disabled", $ids.filter(":checked").size() < 1);
		});
	
		
		
	});
	</script>
</head>
<body class="hold-transition">
	<div id="printModal" class="modal fade" tabindex="-1">
		<div class="modal-dialog">
			<div class="modal-content">
				<div class="modal-header">
					<button class="close" type="button" data-dismiss="modal">&times;</button>
				</div>
				<div class="modal-body text-center">
					<select id="printSelect" class="selectpicker">
						<option value="purchase">sku单位维护</option>
						<option value="stock">sku单位维护</option>
					</select>
				</div>
				<div class="modal-footer">
					<button id="printButton" class="btn btn-primary" type="button">${message("business.common.ok")}</button>
					<button class="btn btn-default" type="button" data-dismiss="modal">${message("business.common.cancel")}</button>
				</div>
			</div>
		</div>
	</div>
	<div class="container-fluid">
		<section class="content-header">
			<h1>sku单位</h1>
			<ol class="breadcrumb">
				<li>
					<a href="${base}/business/index/main">
						<i class="fa fa-home"></i>
						${message("business.common.index")}
					</a>
				</li>
				<li class="active">sku单位</li>
			</ol>
		</section>
		<section class="content">
			<div class="row">
				<div class="col-xs-12">
					<form action="${base}/admin/unit/list" method="post">
						<input name="pageable.pageSize" type="hidden" value="${pageable.pageSize}">
						<input name="pageable.pageNumber" type="hidden" value="${pageable.pageNumber}">
						<input name="pageable.searchProperty" type="hidden" value="${pageable.searchProperty}">
						<input name="pageable.orderProperty" type="hidden" value="${pageable.orderProperty}">
						<input name="pageable.orderDirection" type="hidden" value="${pageable.orderDirection}">
						<div class="box">
							<div class="box-header">
								<div class="row">
									<div class="col-xs-9">
										<div class="btn-group">
											<a class="btn btn-default" href="${base}/admin/unit/add">
												<i class="fa fa-plus"></i>
												${message("business.common.add")}
											</a>
											<button class="btn btn-default" type="button" data-toggle="delete" disabled>
												<i class="fa fa-times"></i>
												${message("business.common.delete")}
											</button>
											<button class="btn btn-default" type="button" data-toggle="refresh">
												<i class="fa fa-refresh"></i>
												${message("business.common.refresh")}
											</button>
											<div class="btn-group">
												<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
													${message("business.common.pageSize")}
													<span class="caret"></span>
												</button>
												<ul class="dropdown-menu">
													<li[#if pageable.pageSize == 10] class="active"[/#if] data-page-size="10">
														<a href="javascript:;">10</a>
													</li>
													<li[#if pageable.pageSize == 20] class="active"[/#if] data-page-size="20">
														<a href="javascript:;">20</a>
													</li>
													<li[#if pageable.pageSize == 50] class="active"[/#if] data-page-size="50">
														<a href="javascript:;">50</a>
													</li>
													<li[#if pageable.pageSize == 100] class="active"[/#if] data-page-size="100">
														<a href="javascript:;">100</a>
													</li>
												</ul>
											</div>
										</div>
									</div>
									<div class="col-xs-3">
										<div class="box-tools">
											<div id="search" class="input-group">
												<div class="input-group-btn">
													<button class="btn btn-default" type="button" data-toggle="dropdown">
														[#switch pageable.searchProperty]
															[#case "sn"]
																<span>单位id</span>
															[#break]
															[#default]
																<span>单位名称</span>
														[/#switch]
														<i class="caret"></i>
													</button>
													<ul class="dropdown-menu">
														<li[#if pageable.searchProperty == "p.id"] class="active"[/#if] data-search-property="p.sn">
															<a href="javascript:;">单位id</a>
														</li>
														<li[#if !pageable.searchProperty?? || pageable.searchProperty == "name"] class="active" [/#if] data-search-property="name">
															<a href="javascript:;">单位名称</a>
														</li>
													</ul>
												</div>
												<input name="pageable.searchValue" class="form-control" type="text" value="${pageable.searchValue}" placeholder="${message("business.common.search")}">
												<div class="input-group-btn">
													<button class="btn btn-default" type="submit">
														<i class="fa fa-search"></i>
													</button>
												</div>
											</div>
										</div>
									</div>
								</div>
							</div>
							<div class="box-body table-responsive no-padding">
							
								<table class="table table-hover">
									<thead>
										<tr>
											<th>
												<i class="check-all fa fa-square-o" data-toggle="checkAll"></i>
											</th>
											<th>
												<a href="javascript:;" data-order-property="id">
													单位名称
													<i class="fa fa-sort"></i>
												</a>
											</th>
											
											<th>
												<a href="javascript:;" data-order-property="createdDate">
													${message("business.common.createdDate")}
													<i class="fa fa-sort"></i>
												</a>
											</th>
											
											<th>${message("business.common.action")}</th>
										</tr>
									</thead>
									<tbody>
										[#list page.list as unit]
											<tr>
												<td>
													<input id="input_unit_id" name="ids" type="checkbox" value="${unit.id}">
												</td>
												<td>${unit.name}
												<input name="input_unit_name" type="hidden" value="${unit.name}">
												</td>
												
												<td>
													<span title="${unit.createdDate?string("yyyy-MM-dd HH:mm:ss")}">${unit.createdDate}</span>
												</td>
												
												<td>
												<a name="a_unit_update" class="btn btn-default" href="${base}/admin/unit/edit?unitId=${unit.id}">修改</a>
												<a name="a_unit_delete" class="btn btn-default" href="javascript:void(0);">删除</a>
												</td>
											</tr>
										[/#list]
									</tbody>
								</table>
								[#if !page.list?has_content]
									<p class="no-result">${message("business.common.noResult")}</p>
								[/#if]
							</div>
							[@pagination pageNumber = page.pageNumber totalPages = page.totalPage]
								[#if totalPages > 1]
									<div class="box-footer clearfix">
										[#include "/business/include/pagination.ftl"]
									</div>
								[/#if]
							[/@pagination]
						</div>
					</form>
				</div>
			</div>
		</section>
	</div>
</body>
</html>